﻿
#region Usings

using FasterWPF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using System.Windows.Markup;
using wpfToolkit = Xceed.Wpf.Toolkit;

#endregion

namespace FasterWPFDemo
{
    public static class GlobalStoreService
    {
        public static class TabControlGuids
        {
            public static string One = "A2325F82-6F1A-4973-B5F8-251635D4564F";
            public static string Two = "944AB79E-81E2-490C-8E84-DF01643C6D77";
            public static string Three = "2A80862F-A26D-44C1-A057-13DD57049BF0";
            public static string Four = "3AD768B7-2387-4DA9-8669-C8C045503914";
            public static string Five = "07638AD6-7418-4A3A-BB6E-D559E12F1BFB";
            public static string Six = "371639D3-7185-446B-B1E0-9CFEAA7BAE31";
            public static string Seven = "4E7F7712-3D31-4AE9-B7F1-6B7B84F1848C";
            public static string Eight = "F40E2BB5-EF4B-4822-A4C5-1C6C25D9FD5C";
            public static string Nine = "09E61325-1570-4898-93A7-8F1BB8F62CDD";
            public static string Ten = "C24EB655-9417-458E-946A-1BE1E5AE802F";
        }

        public static void CreateGlobalStores()
        {
            Application.Current.Properties[TabControlGuids.One] = new Dictionary<string, object>();
            Application.Current.Properties[TabControlGuids.Two] = new Dictionary<string, object>();
            Application.Current.Properties[TabControlGuids.Three] = new Dictionary<string, object>();
            Application.Current.Properties[TabControlGuids.Four] = new Dictionary<string, object>();
            Application.Current.Properties[TabControlGuids.Five] = new Dictionary<string, object>();
            Application.Current.Properties[TabControlGuids.Six] = new Dictionary<string, object>();
            Application.Current.Properties[TabControlGuids.Seven] = new Dictionary<string, object>();
            Application.Current.Properties[TabControlGuids.Eight] = new Dictionary<string, object>();
            Application.Current.Properties[TabControlGuids.Nine] = new Dictionary<string, object>();
            Application.Current.Properties[TabControlGuids.Ten] = new Dictionary<string, object>();
        }

        public static void PutInGlobalStore(string tabCtlGuid, string key, object value)
        {
            ((Dictionary<string, object>)Application.Current.Properties[tabCtlGuid]).Add(key, value);   
        }

        public static T GetFromGlobalStore<T>(string tabCtlGuid, string key)
        {
            return (T)((Dictionary<string, object>)Application.Current.Properties[tabCtlGuid])[key];   
        }

        public static bool ExistsInGlobalStore(string tabCtlGuid, string key)
        {
            return ((Dictionary<string, object>)Application.Current.Properties[tabCtlGuid]).ContainsKey(key);
        }

        public static void RemoveFromGlobalStore(string tabCtlGuid, string key)
        {
            ((Dictionary<string, object>)Application.Current.Properties[tabCtlGuid]).Remove(key);
        }

        public static void ClearGlobalStoreByGuid(string tabCtlGuid)
        {
            ((Dictionary<string, object>)Application.Current.Properties[tabCtlGuid]).Clear();
        }

    }//end of class
} //end of namespace
